package com.icoopoo.modules.transaction.service.imp;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.icoopoo.modules.transaction.dao.TransactionDao;
import com.icoopoo.modules.transaction.model.TransactionModel;
import com.icoopoo.modules.transaction.service.TransactionService;

@Transactional
@Service
public class TransactionServiceImpl implements TransactionService{

	@Autowired
	private TransactionDao dao;
	@Override
	public int save(TransactionModel model) {

		int saveId = dao.save(model);
		return saveId;
	}
	@Override
	public int update(TransactionModel model) {
		
		int updateId = dao.update(model);
		return updateId;
	}
	@Override
	public int saveException(TransactionModel model) throws Exception {
		int saveId = dao.saveException(model);
		int a = 4/0;
		throw new RuntimeException("保存之前，抛出异常！");
	}
	@Override
	public int updateException(TransactionModel model) throws Exception {
		int updateId = dao.updateException(model);
		throw new RuntimeException("更新之后，抛出异常！");
	}
	
}
